#include<bits/stdc++.h>
#define ll long long
using namespace std;
int rd()
{
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c))
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(isdigit(c))
	{
		x=x*10+c-48;
		c=getchar();
	}
	return x*f;
}
ll lrd()
{
	ll x=0,f=1;
	char c=getchar();
	while(!isdigit(c))
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(isdigit(c))
	{
		x=x*10+c-48;
		c=getchar();
	}
	return x*f;
}
const int N=1e5+10;
int n,m;
ll L,V;
struct car
{
	ll d,v,a,dis;
	int nxt;
}c[N];
ll det[N];
void sola()
{
	int ans=0;
	for(int i=1;i<=n;i++)
		if(c[i].v>V&&det[m]>=c[i].d)
			ans++;
	if(ans==0)
		cout<<ans<<' '<<m<<endl;
	else
		cout<<ans<<' '<<m-1<<endl;
}
void solb()
{
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(c[i].d>det[m])
			continue;
		ll vfang=c[i].v*c[i].v+2*c[i].a*(det[m]-c[i].d);
		if(vfang>V*V)
			ans++;
	}
	if(ans==0)
		cout<<ans<<' '<<m<<endl;
	else
		cout<<ans<<' '<<m-1<<endl;
}
bool cmp(car x,car y)
{
	return x.d<y.d;
}
int getnxt(int x)
{
	int l=1,r=m;
	int ans=m;
	while(l<r)
	{
		int mid=(l+r)/2;
		if(det[mid]>=x)
		{
			r=mid;
			ans=min(r,ans);
		}	
		else
			l=mid+1;
	}
	return ans;
}
void solc()
{
	
}
int main()
{
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int T=rd();
	while(T--)
	{
		n=rd(),m=rd(),L=lrd(),V=lrd();
		bool fa=1,fb=1,fc=1;
		for(int i=1;i<=n;i++)
		{
			c[i].d=lrd(),c[i].v=lrd(),c[i].a=lrd();
			if(c[i].a!=0)fa=0;
			if(c[i].a<=0)fb=0;
			if(c[i].a>=0)fc=0;
		}	
		for(int i=1;i<=m;i++)
			det[i]=rd();
		sort(det+1,det+m+1);
		if(fa)
		{
			sola();
			continue;
		}
		if(fb)
		{
			solb();
			continue;
		}
		if(fc)
		{
			solc();
			continue;
		}
	}	
	return 0;
}
